package com.zhl.hadoop.mapreduce.partition;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Counter;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @program: demos
 * @description:
 * @author: 刘振华
 * @create: 2020-10-28 11:11
 **/
public class PartitionReduce extends Reducer<Text, NullWritable,Text,NullWritable> {

	@Override
	protected void reduce(Text key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
		//第二种方式，枚举
		Counter counter = context.getCounter(CountEnum.MY_INPUT_RECORDS);
		counter.increment(1L);
		context.write(key,NullWritable.get());
	}
}
